package com.fyzk.activity.prize.detail;

import android.os.Bundle;
import android.view.View;

import com.fyzk.base.BaseActivity;
import com.fyzk.activity.prize.InquiryInfo;
import com.fyzk.activity.prize.item.PrizeItemBase;
import com.fyzk.activity.prize.item.PrizeItemFactory;
import com.fyzk.bean.AwardDetail;
import com.fyzk.data.AppLotteryInfos;
import com.fyzk.interfaces.onTopTitleClickListener;
import com.tyjc.lottery.R;
import com.fyzk.utils.IntentParamUtils;
import com.fyzk.view.TopTitleView;

import java.util.ArrayList;
/**
 * 高频彩 开奖详情 基类
 */
public abstract class GaoPinPrizeDetailBaseActivity extends BaseActivity implements onTopTitleClickListener {

	private TopTitleView mVi_topTitle;
	private PrizeSelectDetailTopView mVi_prizeNumView;
	private PrizeDetailSalesBonusView mVi_salesAndBonus;
	private PrizeDetailAwardLevelView mVi_levelDetail;
	private int mStr_lotteryID;
	private String mStr_lotteryPeriod;
	private String mStr_prizeNum;// 
	private String mStr_prizeDate;//

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.dj_activity_prizedetail);
		mStr_lotteryID = getIntent().getIntExtra(IntentParamUtils.LOTTERYID, 0);
		mStr_lotteryPeriod = getIntent().getStringExtra(IntentParamUtils.PERIOD);
		mStr_prizeNum = getIntent().getStringExtra(IntentParamUtils.PRIZENUM);
		mStr_prizeDate = getIntent().getStringExtra(IntentParamUtils.DATE);

		// mId_lotteryName = LotteryNameUtils.getLotteryName(mStr_lotteryID);
		init();

	}

	@Override
	protected void init() {
		// TODO Auto-generated method stub
		mVi_topTitle = (TopTitleView) findViewById(R.id.topTitle);

		String lotteryName = AppLotteryInfos.getLotteryName(mStr_lotteryID);

		mVi_topTitle.setCenterText(lotteryName + getResources().getString(R.string.text_prizedetail_open));
		mVi_topTitle.setRightVisible(View.INVISIBLE);
		mVi_topTitle.setOnTitleClickListener(this);

		mVi_prizeNumView = (PrizeSelectDetailTopView) findViewById(R.id.ttc_activity_prizedetail_Vi_prizeball);
		mVi_prizeNumView.setLotteryName(lotteryName);
		mVi_prizeNumView.setDate(mStr_prizeDate);
		mVi_prizeNumView.setPeriod(mStr_lotteryPeriod);
		InquiryInfo info = new InquiryInfo(mStr_lotteryID, "", mStr_prizeNum, "", mStr_lotteryPeriod, mStr_prizeDate);
		PrizeItemBase prizeItem = PrizeItemFactory.getInstance().getPrizeItem(info);
		mVi_prizeNumView.setPrizeNum(prizeItem);

		mVi_salesAndBonus = (PrizeDetailSalesBonusView) findViewById(R.id.ttc_activity_prizedetail_Vi_salesBonus);
		mVi_salesAndBonus.setVisibility(View.GONE);
		mVi_levelDetail = (PrizeDetailAwardLevelView) findViewById(R.id.ttc_activity_prizedetail_Vi_levelView);
		mVi_levelDetail.isGaoPin();
		mVi_levelDetail.setAwardsList(getGpPrizeData());
	}

	
	public abstract int getPrizeNameArrayId();
	public abstract int getPrizeAmtArrayId();
	
	public ArrayList<AwardDetail.LevelsBean> getGpPrizeData() {
		// TODO Auto-generated method stub
		String[] prizeNames = this.getResources().getStringArray(getPrizeNameArrayId());
		String[] prizeAmts = this.getResources().getStringArray(getPrizeAmtArrayId());
		int length = prizeNames.length;
		ArrayList<AwardDetail.LevelsBean> infos = new ArrayList<AwardDetail.LevelsBean>();
		for (int i = 0; i < length; i++) {
			AwardDetail.LevelsBean info = new AwardDetail.LevelsBean();
			info.setLevel(prizeNames[i]);
			info.setAmount(prizeAmts[i]);
			infos.add(info);
		}

		return infos;
	}


	@Override
	public void onLeftClick() {
		// TODO Auto-generated method stub
		finish();
	}

	@Override
	public void onCenterClick() {
		// TODO Auto-generated method stub

	}

	@Override
	public void onRightClick() {
		// TODO Auto-generated method stub

	}

	@Override
	public void onRight2Click() {
		// TODO Auto-generated method stub

	}
}